﻿@using Abp.Extensions
@using FutureGoodsBrand = FutureApp.Shop.GoodsBrand
@model FutureApp.Shop.Dto.GoodsBrandEntityDto

@section Scripts{
    <script>
        !function ($) {
            var $$$ = function () {
                this.$box = $('.box');
                this.$form = $('form');
                this.service = abp.services.app.goodsBrand;
                this.localize = abp.localization.localize;
            };
            $$$.prototype = {
                init: function () {
                    this.formSubmit();
                    this.binding();
                },
                formSubmit: function () {
                    this.$form.submit(function (e) {
                        e.preventDefault();
                    });
                },
                binding: function () {
                    var self = this;
                    self.$box.on("click", '.btn', function (e) {
                        e.preventDefault();

                        var $sender = $(e.currentTarget);
                        var action = $.trim($sender.data("action"));
                        switch (action) {
                            case "submit":
                                self.submit();
                                break;
                        }
                    });
                },
                submit: function () {
                    var self = this;
                    abp.ui.setBusy(self.$box);
                    var data = self.$form.serializeFormToObject();
                    self.service.createGoodsBrand(data)
                        .done(function () {
                            abp.message.success(self.localize("AddGoodsBrandSucceed"))
                                .done(function () { location.href = "@Url.Action("list")"; });
                        })
                        .always(function () {
                            abp.ui.clearBusy(self.$box);
                        });
                }
            };

            $(function () { (new $$$()).init(); });
        }(jQuery);
    </script>
}
<ul class="content-nav">
    <li>
        <a href="@Url.Action("list")">@L("List")</a>
    </li>
    <li class="active">
        <a href="javascript:;">@L("Add")</a>
    </li>
</ul>
<div class="box box-success box-edge-all" data-dock="true">
    <form role="form" class="col-xs-10">
        <div class="box-body">
            <div class="form-group">
                <label>@L("GoodsBrandName")</label>
                <input name="Name" type="text" class="form-control" maxlength="@FutureGoodsBrand.MaxNameLength" autofocus>
            </div>
        </div>
        <div class="box-footer">
            <a class="btn btn-primary" href="javascript:;" data-action="submit">
                <i class="fa fa-check"></i>
                @L("Submit")
            </a>
        </div>
    </form>
</div>